package com.song.utils;

import com.song.polo.Administrator;
import com.song.polo.Express;
import org.springframework.beans.factory.annotation.Autowired;

import java.sql.ResultSet;
import java.sql.SQLException;

/**数据库对象保存
 * @author song
 */
public class TemplateUtil {
    /**
     * 管理员数据库对象的数据获取保存
     * @param resultSet
     * @return
     * @throws SQLException
     */
    public static Administrator getObject(ResultSet resultSet) throws SQLException {
        Administrator administrator = new Administrator();
        administrator.setAdministratorId(resultSet.getInt("administratorId"));
        administrator.setAdministratorName(resultSet.getString("administratorName"));
        administrator.setPassword(resultSet.getString("password"));
        administrator.setAdministratorPhone(resultSet.getString("administratorPhone"));
        return administrator;
    }

    public static Express getExpress(ResultSet resultSet) throws SQLException{
        Express express = new Express();
        express.setExpressId(resultSet.getInt("expressId"));
        express.setExpressNumber(resultSet.getString("expressNumber"));
        express.setCompany(resultSet.getString("company"));
        express.setReceiverName(resultSet.getString("receiverName"));
        express.setReceiverPhone(resultSet.getString("receiverPhone"));
        express.setCode(resultSet.getString("code"));
        express.setInputTime(resultSet.getTimestamp("inputTime"));
        express.setOutputTime(resultSet.getTimestamp("outputTime"));
        express.setStatus(resultSet.getInt("status"));
        express.setWriterPhone(resultSet.getString("writerPhone"));
        return express;
    }
}
